<?php
class Travel_model extends MY_Model {

  function __construct(){
    parent::__construct();
    $this->_table = "ci_post";
    $this->_prefix = "pos";
    $this->_column = array(
                'id'            =>$this->_prefix."_id",
                'name'          =>$this->_prefix."_name",
                'impression'    =>$this->_prefix."_impression",
                'content'       =>$this->_prefix."_content",
                'usr_ip'        =>$this->_prefix."_usr_ip",
                'status'        =>$this->_prefix."_status",
                'comment_status'=>$this->_prefix."_comment_status",
                'usr_id'        =>$this->_prefix."_usr_id",
                'tag_def'       =>$this->_prefix."_tag_def",
                'typ_id'        =>$this->_prefix."_typ_id",
                'cr_date'       =>$this->_prefix."_cr_date",
                'lu_date'       =>$this->_prefix."_lu_date",
                'lu_uid'        =>$this->_prefix."_lu_uid",
                'update_date'   =>$this->_prefix."_update_date",
                'url'           =>$this->_prefix."_url",
                'type'          =>$this->_prefix."_type",
                'code'          =>$this->_prefix."_code",
                'view'          =>$this->_prefix."_view",
                'lat'           =>$this->_prefix."_lat",
                'lng'           =>$this->_prefix."_lng",
                'comment_count' =>$this->_prefix."_comment_count",
                'parent_id'          =>$this->_prefix."_parent_id"
    );
    $this->_join_column = array(
                            'img_id'          => "img_id",
                            'img_pos_id'      => "img_pos_id",
                            'img_filename'    => "img_filename",
                            'img_firstimage'  => "img_firstimage",
                            'img_small'       => "img_small",
                            'img_medium'      => "img_medium",
                            'tag_name'        => "tag_name",
                            'tag_url'         => "tag_url",
                            'cat_tag_id'      => "cat_tag_id",
                            'cat_panrent_id'  => "cat_parent_id"
    );
  }

  function get($options = NULL){
    $this->db->where("pos_type","travel");
    return parent::get($options);
  }

   function getImage($options = NULL){
    $this->db->where("pos_type","travel");
    $this->db->join('ci_images','ci_images.img_pos_id = ci_post.pos_id');
    /*$this->db->join("ci_category_post","ci_post.pos_id = ci_category_post.ctp_pos_id");
    $this->db->join("ci_category","ci_category_post.ctp_cat_id = ci_category.cat_id");
    $this->db->join("ci_tag","ci_category.cat_tag_id = ci_tag.tag_id");*/
    $travel = parent::get($options);
    if(!empty($travel)){
    foreach ($travel as $key => $value) {
        $travel[$key]["user"] = $this->ion_auth->user_array($value["usr_id"]);

        }  
    }
    return $travel;
    }
  
}
?>